package myapp.com.myapplication;

import com.xm.httpapi.BaseApi.BaseApi;

/**
 *
 */

public class Api extends BaseApi {
    private volatile static Api instance;
    private ApiService service;

    private Api() {
        super(BuildConfig.url, BuildConfig.timeOut, BuildConfig.ReponseSucessCode,
                BuildConfig.ReponseTokenInvalidCode);
    }

    public static Api getInstance() {
        if (instance == null) {
            synchronized (Api.class) {
                if (instance == null) {
                    instance = new Api();
                }
            }
        }
        return instance;
    }

    public static ApiService getApi() {
        return getInstance().getDefault();
    }

    public void clearApiService() {
        if (service != null) service = null;
    }

    public ApiService getDefault() {
        return service == null ? service = getRetrofit().create(ApiService.class) : service;
    }


}
